package com.itheima.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.itheima.domain.Book;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * className: BookServiceTestCase
 * description:
 * date: 2023/2/22 0022-PM 11:03:23
 * <p>
 * project: springboot
 * package: com.itheima.service
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
@SpringBootTest
public class BookServiceTestCase {

    @Autowired
    private IBookService booksService;

    @Test
    void testGetById() {
        System.out.println(booksService.getById(4));
    }

    @Test
    void testSave() {
        Book book = new Book();
        book.setType("测试数据123");
        book.setName("测试数据123");
        book.setDescription("测试数据123");
        booksService.save(book);
    }

    @Test
    void testUpdate() {
        Book book = new Book();
        book.setId(17);
        book.setType("测试数据abcdefg");
        book.setName("测试数据123");
        book.setDescription("测试数据123");
        booksService.modify(book);
    }

    @Test
    void testDelete() {
        booksService.delete(15);
    }

    @Test
    void testGetAll() {
        booksService.list();
    }

    @Test
    void testGetPage() {
        IPage<Book> page = booksService.getPage(2, 5);
        System.out.println(page.getCurrent());
        System.out.println(page.getSize());
        System.out.println(page.getTotal());
        System.out.println(page.getPages());
        System.out.println(page.getRecords());
    }
}
